﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace storeSMS
{
    public partial class frmSDSend : Form
    {
        private string phone="";
        public frmSDSend()
        {
            InitializeComponent();
        }
        public frmSDSend(string p)
        {
            phone = p;
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string sms = txtPhone.Text.Trim();
            string con = txtContent.Text.Trim();
            if (sms != "" && con != "")
            {
                SMSMessage.Send(sms.Split(','), con, 0);
            }
            else {
                MessageBox.Show("发送人或内容不能为空！");
            }
        }

        private void frmSDSend_Load(object sender, EventArgs e)
        {
            if (phone != "")
            {
                this.txtPhone.Text = phone;
            }
            BLL.linkers bl = new BLL.linkers();
            DataSet ds = bl.GetAllList();

            clblinker.DataSource = ds.Tables[0];
            clblinker.DisplayMember = "uname";
            clblinker.ValueMember = "uphone";
        }

        private void btnclose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void clblinker_SelectedIndexChanged(object sender, EventArgs e)
        {
            string s = "";
            for (int i = 0; i < clblinker.CheckedItems.Count; i++)
            {
                //if (clblinker.GetItemChecked(i))
                //{
                    DataRowView dv = ((DataRowView)clblinker.CheckedItems[i]);
                    string id = dv["uphone"].ToString();
                    s+=id+",";
                //}
            }
            if (s != "")
                s = s.Substring(0, s.Length - 1);
            txtPhone.Text = s;
        }
    }
}
